package com.youngjun.user.controller.admin;

import com.youngjun.common.mybatis.page.PageInfo;
import com.youngjun.common.mybatis.page.PageParams;
import com.youngjun.common.mybatis.web.BaseController;
import com.youngjun.common.mybatis.web.Response;
import com.youngjun.user.api.admin.IOrganizationRestApi;
import com.youngjun.user.pojo.dto.ProfileDTO;
import com.youngjun.user.pojo.dto.query.OrganizationQueryDTO;
import com.youngjun.user.pojo.vo.ProfileVO;
import com.youngjun.user.service.OrganizationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/organization")
public class OrganizationController implements IOrganizationRestApi,BaseController {

    @Autowired
    OrganizationService organizationService;

    @Override
    public Response<PageInfo<ProfileVO>> queryList(@RequestBody OrganizationQueryDTO dto) {
        PageParams pageParams = getPageParams(dto);
        List<ProfileVO> data = organizationService.queryList(dto,pageParams);
        return new Response<>(new PageInfo<>(data,pageParams));
    }

    @Override
    public Response<ProfileVO> create(@RequestBody ProfileDTO dto) {
        ProfileVO data = organizationService.create(dto);
        return new Response<>(data);
    }

    @Override
    public Response<ProfileVO> modify(@RequestBody ProfileDTO dto) {
        ProfileVO data = organizationService.modify(dto);
        return new Response<>(data);
    }

}